<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>插槽的基本使用</title>
  <style>
    #app {
      margin-top: 50px;
      text-align: center;
    }
  </style>
</head>

<body>

  <div id="app">
    <!-- 1. 下列方式会把插槽中的预留插槽全部替换 -->
    <!-- <cpn><span>标题</span></cpn>  -->

    <!-- 2. 使用具名插槽 -->
    <cpn><span slot="center">标题</span></cpn>
    <cpn></cpn>
  </div>


  <template id="cpn">
    <div>
      <!-- 1. 具名插槽: 给插槽起名字 -->
      <slot name="left"><span>左边</span></slot>
      <slot name="center"><span>中间</span></slot>
      <slot name="right"><span>右边</span></slot>
      <hr>
    </div>
  </template>

  <script src="../../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {},
      components: {
        cpn: {
          template: '#cpn'
        }
      }
    })
  </script>
</body>

</html>